package com.wyf.springbootmybatis.po;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;


/**
 * 数据校验
 *   当校验不通过时，会被全局异常处理器所捕获（BindException）
 */
@Data
@ApiModel(description = "相应结果-用户信息")
@TableName(value = "tb_user", autoResultMap = true)
public class User {
    @ApiModelProperty(value = "用户id", example = "0")
    @TableId(value = "user_id")
    private Integer userId;

    @ApiModelProperty(value = "用户名")
    @NotBlank(message = "用户名不能为空")
    private String userName;

    @ApiModelProperty(value = "用户密码")
    @NotBlank(message = "密码不能为空")
    @Length(min = 4, max = 10, message = "用户密码长度在4-10位之间")
    private String userPwd;

    @Email // 如果userEmail为空不校验，不为空则进行Email校验
    private String userEmail;
}
